package cn.nawang.ebeim.uc.util;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.nawang.ebeim.client.util.PropertiesUtil;

public class ConfigUtil {
  private static final Logger LOG = LoggerFactory.getLogger(ConfigUtil.class);
  
  private static Map<String, String> props = new HashMap<String, String>();
  
  static {
    try {
      props = PropertiesUtil.readAll();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
  
  public static int getRestServerPort() {
    String strPort = props.get(ConfigConstants.REST_SERVER_PORT);
    int port = ConfigConstants.DEFAULT_REST_SERVER_PORT;
    if (strPort != null) {
      try {
        port = Integer.valueOf(strPort);
      } catch (Exception e) {
        LOG.info("rest.server.port can't be parsed, use default. {}", e.getMessage());
      }
    }
    return port;
  }

}
